import React from 'react';
import {Card, Descriptions, Space} from "antd";
import {Link, useLocation} from "react-router-dom";
import {ArrowLeftOutlined} from "@ant-design/icons";
import {SecurityMenu} from "type/SecurityMenu";
import {getTag} from "util/ColumnsUtil";

import InitHandler from "global/InitHandler";

const IconFont = InitHandler.getInstance().getIconFont() ;
const MenuDetailsComponent = () => {

    const state: SecurityMenu = useLocation().state ;

    return (
        <Card
            title={ <Space>
                <Link key={"menu-list"} to={""}><ArrowLeftOutlined/></Link>
                <span>菜单详细信息</span>
            </Space> }
            extra={<Link key={"menu-list"} to={""}>Menu list</Link>}
        >
            <Descriptions
                column={2}
                bordered={true}
                items={[
                    {
                        key: 'id',
                        label: '菜单编号',
                        children: state.id
                    },
                    {
                        key: 'key',
                        label: 'KEY',
                        children: state.key
                    },
                    {
                        key: 'parentId',
                        label: '父级编号',
                        children: state.parentId
                    },
                    {
                        key: 'label',
                        label: '菜单标签',
                        children: state.label
                    },
                    {
                        key: 'describe',
                        label: '功能描述',
                        children: state.describe
                    },
                    {
                        key: 'path',
                        label: '路径地址',
                        children: state.path
                    },
                    {
                        key: 'icon',
                        label: '图标样式',
                        children: <IconFont type={state.icon}/>
                    },
                    {
                        key: 'last' ,
                        label: '子菜单',
                        children: getTag(state.last,"子菜单","父菜单")
                    },
                    {
                        key: 'order' ,
                        label: '数据排序',
                        children: state.order
                    },
                    {
                        key: 'menuOrder' ,
                        label: '菜单排序',
                        children: state.menuOrder
                    },
                    {
                        key: 'delete',
                        label: '删除状态',
                        children: getTag(!state.delete,"未删除","已删除")
                    },
                    {
                        key: 'version',
                        label: '数据版本',
                        children: state.version
                    },
                    {
                        key: 'createTime',
                        label: '创建时间',
                        children: state.createTime.toString()
                    },
                    {
                        key: 'updateTime',
                        label: '更新时间',
                        children: state.updateTime.toString()
                    },
                    {
                        key: 'remark',
                        label: '备注信息',
                        children: state.remark
                    }
                ]}
            />
        </Card>
    );
};

export default MenuDetailsComponent;